PDA - Core-Script Library

Core Script Library Application

The Core Script Library for M-Files adds a library of supporting functions to M-Files for use in EventHandlers and Workflow Scripts.

Pentagon Help resources:

Pentagon Product Help

PentagonDocs Assistant

PentagonMail Assistant

Help for specific Applications: (these will open in a new browser window)

Core Script Library (you are here)

DWG Processor

Extranet Uploader

Notifications Processor

PDF Processor

Transmittals

Copyright © Pentagon Solutions Ltd. All Rights Reserved.


Log Files

The Core Script Library allows the generation of log files during it's operation via the WriteLog function. The log files are useful when trying to determine why a particular Script might have failed.

The log files are created on the M-Files server in the following location: C:\ProgramData\Pentagon DOCS\Server Logs\<Vault Name> <Vault GUID>

Each vault with the Core Script Library installed will have its own Server Logs sub folder based on the display name of the vault and it's globally unique identifier (GUID).

Automatic Removal of Log Files

Because the creation of log files can be based on an activity or transaction, the number of log files can quickly accumulate. The Core Script library will automatically remove log files older than 24 hours.

This setting can be increased or decreased by changing the following registry entry:

Registry Key | HKEY_LOCAL_MACHINE\SOFTWARE\PentagonDOCS\Server
Value Name | DeleteLogFilesAfterHours
Type | REG_DWORD
Default | 0x00000018 (24) 24 Hours

Changing of this value does not require the vault to be restarted.


Prerequisites

Installation ››

Before installing the Core Script Library on your M-Files Server, please ensure the prerequisites listed below have been met.

    • M-Files Server 2015.3 (11.3.4330.196) or above
    • Microsoft .NET Framework 4.7.2 or above
    • Core Script Library License File


Server Installation

Installation ››

To add the Core Script Library to a vault, open the M-Files Admin tool on the server. Navigate to 'Connections to M-Files Servers\Local Computer\Document Vaults' then right-click on the vault you want to install the application. From the context menu, select 'Applications'.

This displays the Applications dialogue box. Click the 'Install...' button.

Browse to the location of your application file. Pentagon_Core_Script Library x_x_x_x.mfappx

You will be prompted to restart the chosen vault. Click 'Yes' to restart the vault.

Once installed the Server application will be displayed in the Applications interface.

Note: The application will need to be licensed before users are able to upload documents.

See Also

Licensing


Licensing

Installation ››

Before you can use the Core Script Library, you need to install a valid license. A license file can be obtained from Pentagon and is linked to the M-Files installation via the M-Files License Serial Number (xxx-xxxxxxxx).

After installation , the Application has a status of 'No license is installed'. Each Vault with the Core Script Library Application will need to have a license added. the same license file can be used across multiple Vaults on the same M-Files server. to add a license to the a Vault, open the M-Files Admin tool on the server. Navigate to 'Connections to M-Files Servers\Local Computer\Document Vaults' then right-click on the Vault you wish to install the License too. From the context menu, select 'Applications'

In the Applications window, select the 'Pentagon DOCS Core Script Library' application then click the 'License' button as shown below:

Browse and select the License File (*.lic). Then click 'Open'. The License status, will change to 'The License is valid' provided everything is correct.

The Application window also shows the license as valid

Close the Applications window.


Script Functions

Copyright © Pentagon Solutions Ltd. All Rights Reserved.


CheckIn

Script Functions ››

Description

Check's in the supplied object's to the vault.

Syntax

Sub CheckIn(Vault As Vault, ObjVer As ObjVer)

Parameters

Name | Data Type | Description
Vault | Vault | Vault that contains the
ObjVer | ObjVer | ObjVer of the Object to check in.

Return

Nothing

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("ExDOCS.Core.ScriptLibrary")

'Checkin object to vault

scriptLib.Checkin(Vault, ObjVer)


CheckOut

Script Functions ››

Description

Check out the object's from the vault.

Syntax

Function CheckOut(Vault As Vault, ObjVer As ObjVer) As ObjVer

Parameters

Name | Data Type | Description
Vault | Vault | Vault that contains the
ObjVer | ObjVer | ObjVer of the Object to check out.

Return

Returns the ObjVer containing information on the object after checkout

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("ExDOCS.Core.ScriptLibrary")

'Checkin object to vault

scriptLib.CheckOut(Vault, ObjVer)


CopyObjectWithFiles

Script Functions ››

Description

Creates a copy of an existing object including any files.

Syntax

Function CopyObjectWithFiles(Vault As Vault, ObjVer As ObjVer) As ObjVer

Parameters

Name | Data Type | Description
Vault | Vault | Vault object that contains the ObjVer
ObjVer | ObjVer | ObjVer of the the object to copy

Return

Returns the new ObjVer of the copied object.

Note: The ObjVer returned does not work with M-Files API functions.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("ExDOCS.Core.ScriptLibrary")

'Copy the object

Dim newObjVer : newObjVer = scriptLib.CopyObjectWithFiles(Vault, ObjVer)


DestroyObject

Script Functions ››

Description

Destroys the specified Object.

Syntax

Sub DestroyObject(Vault As Vault, ObjID As ObjID)

Parameters

Name | Data Type | Description
Vault | Vault | Used to determine the filename of the log file. To create a log file for the current activity pass in the provided ActivityID.
ObjVer | ObjVer | A String or Object to write to the log file. If an object is specified, it must be convertible to String.

Return

No return value.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("ExDOCS.Core.ScriptLibrary")

scriptLib.DestroyObject Vault, ObjVer.ObjID


DestroyVersionsWithStates

Script Functions ››

Description

Destroys any previous versions with matching States. The specified ObjVer will not be destroyed, only prior versions are taken into account when checking against the supplied states.

Syntax

Sub DestroyVersionsWithStates(Vault As Vault, ObjVer As ObjVer, WorkflowStates() As Object)

Parameters

Name | Data Type | Description
Vault | Vault | Vault containing the Object and states
ObjVer | ObjVer | Object with previous states to destroy
WorkflowStates | Array | Array of Workflow State ID or Alias

Return

No return value.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("ExDOCS.Core.ScriptLibrary")

scriptLib.DestroyVersionsWithStates(Vault, ObjVer, Array("PDOCS.State.WIP", "PDOCS.State.PrepareForIssue")


GenertateNumberFromClass

Script Functions ››

Description

Generates a new number based on the configuration associated with the object's class.

Syntax

Function GenerateNumberFromClass(Vault As Vault, ObjVer As ObjVer) As String

Parameters

Name | Data Type | Description
Vault | Vault | Vault object that contains the ObjVer
ObjVer | ObjVer | ObjVer of the the generate the new number from

Return

Returns the newly generated number as a string. If the class is not configured to use DOC Numbering, then the function returns "No Number Allocated".

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'get previous Workflow State ID

Dim newNumber : newNumber = scriptLib.GenerateNumberFromClass(Vault, ObjVer)


GetCopyObjectConfiguration

Script Functions ››

Description

Returns an CopyObjectConfiguration object that contains details about the serialised object.

Syntax

Function GetCopyObjectConfiguration(Json As String) As CopyObjectConfiguration

Parameters

Name | Data Type | Description
Json | String | Json data representing the Object to process

Return

Returns a CopyObjectConfiguration object.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

set copyObjConf = scriptLib.GetCopyObjectConfiguration("jsonString")

See Also

CopyObjectConfiguration object

GetTempPublishData


GetFileCountWithExtension

Script Functions ››

Description

Gets the number of files with a given file extension.

Syntax

Function GetFileCountWithExtension(Vault As Vault, ObjVer As ObjVer, Extension As String) As Integer

Parameters

Name | Data Type | Description
Vault | Vault | Vault containing the Object and states
ObjVer | ObjVer | Object with previous states to destroy
Extension | String | File extension to count.

Return

Returns the number of files with the given file extension.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'get property value as TypedValue

Dim project : project = scriptLib.GetFileCountWithExtension(Vault, ObjVer, "dwg")


GetHistoricPropertyValuesAsStrings

Script Functions ››

Description

Gets the previous property values from the supplied Object.

Syntax

Function GetHistoricPropertyValuesAsStrings(Vault As Vault, LatestObjVer As ObjVer, Property As Object) As Object()

Parameters

Name | Data Type | Description
Vault | Vault | Vault containing the Object
LatestObjVer | ObjVer | Object containing property
Property | String / Integer | Property ID or Alias

Return

Returns an Array of property values.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'get previous Workflow State ID

Dim propValues : propValues = scriptLib.GetHistoricPropertyValueAsStrings(Vault, ObjVer,"ExDOCS.Property.Project")


GetNamedValue

Script Functions ››

Description

Returns the value from the collection in the given namespace.

Syntax

Function GetNamedValue(Namespace As String, ValueName As String) As Object

Parameters

Name | Data Type | Description
Namespace | String | Unique identifier for the value collection
ValueName | String | Name of the value to get

Return

Returns the value from the collection in the given namespace. Throws an exception if the value is null.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

value = scriptLib.GetNamedValue("Namespace", "ValueName")


GetPreviousObjVersWithStates

Script Functions ››

Description

Searches the version history for the specified states in descending order. i.e. V4, V3, V2, V1.

Syntax

Function GetPreviousObjVerWithState(Vault As Vault, LastestObjVer As ObjVer, WorkflowStates() As Object) As ObjVer

Parameters

Name | Data Type | Description
Vault | Vault | Vault containing the object to process
ObjVer | ObjVer | ObjVer of the object to process.
WorkflowStates | String / Integer | Workflow State ID or Alias

Return

Returns an array of ObjVer objects that match one of the supplied Workflow States. If no matches found, returns an empty array.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

Set result = scriptLib.GetPreviousObjVerWithState(Vault, ObjVer, Array("ExDOCS.State.Shared", "ExDOCS.State.Published"))


GetPreviousWorkflowStateAlias

Script Functions ››

Description

Returns the alias associated with the ObjVer previous workflow state.

Syntax

Function GetPreviousWorkflowStateAlias(Vault As Vault, objVer As ObjVer) As String

Parameters

Name | Data Type | Description
Vault | Vault | Vault object containing the Object to process
objVer | ObjVer | ObjVer of the object to process

Return

Returns a string containing the state alias.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

Dim previousState

previousState = scriptLib.GetPreviousWorkflowStateAlias Vault, ObjVer


GetPropertyValue

Script Functions ››

Description

Gets a property value using the Property ID or Property Alias.

Syntax

Function GetPropertyValue(Vault As Vault, ObjVer As ObjVer, Property As Object) As TypedValue

Parameters

Name | Data Type | Description
Vault | Vault | Vault containing the Object
ObjVer | ObjVer | ObjVer of the object to process
Extension | String / Integer | Property ID or Property Alias

Return

Returns the property value as a TypedValue , or nothing on error.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'get property value as TypedValue

Dim propVal : Set propVal = scriptLib.GetPropertyValue(Vault, ObjVer, "ExDOCS.Project.Project")

Dim project : project = propVal.DisplayValue


GetPropertyValueAsString

Script Functions ››

Description

Gets a property value using the Property ID or Property Alias.

Syntax

Function GetPropertyValueAsString(Vault As Vault, ObjVer As ObjVer, Property As Object) As String

Parameters

Name | Data Type | Description
Vault | Vault | Vault containing the Object
ObjVer | ObjVer | ObjVer of the object to process
Property | String / Integer | Property ID or Property Alias

Return

Returns the property value as a String. On error returns an empty String.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'get property value as TypedValue

Dim project

project = scriptLib.GetPropertyValueAsString(Vault, ObjVer, "ExDOCS.Property.Project")


GetRelatedDocuments

Script Functions ››

Description

Returns an object that contains all the document objects related by a common value of the specified property.

Syntax

Function GetRelatedDocuments(Vault As Vault, CommonProperty As Object, CommonValue As Object) As RelatedDocuments

Parameters

Name | Data Type | Description
Vault | Vault | The vault containing the documents to process
CommonProperty | String / Integer | Property ID or Alias.
CommonValue | Object | Property value to search for

Return

Returns a RelatedDocuments object. See RelatedDocuments object for more details.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'get related documents

set relatedDocs = scriptLib.GetRelatedDocuments(Vault, "ExDOCS.Property.BaseDocumentNumber", "P001-EXC-ZZ-00-DR-A-0001")

See Also

RelatedDocuments object


GetTempPublishData

Script Functions ››

Description

Returns an object that contains details related to the realised object.

Syntax

Function GetTempPublishData(Json As String) As TempPublishData

Parameters

Name | Data Type | Description
Json | String | Json data representing the Object to process

Return

Returns a TempPublishData object.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'get temp publish data

set tempPublishObj = scriptLib.GetTempPublishData("ExDOCS.Property.BaseDocumentNumber")

See Also

TempPublishData object


GetUserFromLastStateTransition

Script Functions ››

Description

Returns the ID of the user who execute the transition of the specified workflow state.

Syntax

Function GetUserFromLastStateTransition(Vault As Vault, ObjVer As ObjVer, WorkflowState As Object) As Integer

Parameters

Name | Data Type | Description
Vault | Vault | The vault that contains the Object to process
ObjVer | ObjVer | ObjVer of the object to test.
WorkflowState | String / Integer | Workflow State ID or Alias

Return

The ID of the user who execute the transition of the specified workflow state.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'get user from last state transition

userID = scriptLib.GetUserFromLastStateTransition(Vault, ObjVer, "ExDOCS.State.WIP")


IncrementMajorRevision

Script Functions ››

Description

Increments the major revision component of the supplied revision. The method assumes the major revision has a single digit prefix.

e.g. PXX.XX (where X is a numeric character)

The supplied minor revision argument is appended to the incremented major revision. If the minor revision is nothing, then the minor revision is omitted.

Syntax

Function IncrementMajorRevision(Revision As String, MinorRevision As String) As String

Parameters

Name | Data Type | Description
Revision | String | The complete revision code
MinorRevision | String | Minor revision of the incremented revision.

Return

Returns the incremented revision string.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'increment major revision

Output = scriptLib.IncrementMajorRevision("P01.05", "01")

'returns "P02.01"

'increment major revision

Output = scriptLib.IncrementMajorRevision("P01.05", Nothing)

'returns "P02"


IncrementMinorRevision

Script Functions ››

Description

Increments the minor revision component of the supplied revision. The method assumes the supplied revision has a major and minor component.

e.g. PXX.XX (where X is a numeric character)

Syntax

Function IncrementMinorRevision(Revision) As String

Parameters

Name | Data Type | Description
Revision | String | The complete revision code

Return

Returns the incremented revision string.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'increment minor revision

Output = scriptLib.IncrementMinorRevision("P01.05")

'returns "P01.06"


NewVersionWithContent

Script Functions ››

Description

Create new Object version copying the content from an existing object.

Syntax

Function NewVersionWithContent(sourceObjVer As ObjVer, destinationObjVer As ObjVer) As ObjVer

Parameters

Name | Data Type | Description
Vault | Vault | The Vault object provided by the event handler.
sourceObjVer | ObjVer | ObjVer of source object to copy content from.
destinationObjVer | ObjVer | ObjVer of destination object

Return

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'get previous Workflow State ID

Dim newObjVer : newObjVer scriptLib.GetPreviousWorkflowStateID(Vault, SrcObjVer, DstObjVer)


NewStringKvP

Script Functions ››

Description

Create new StringKvP Object, this object can be used to store and retrieve string values.

Syntax

Function NewStringKvP() As StringKvPCollection

Parameters

none

Return

Returns an empty StringKvPCollection object.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'get previous Workflow State ID

Dim newKVP

Set newKVP = scriptLib.NewStringKvP

See Also

StringKvPCollection


ObjVerFromJSON

Script Functions ››

Description

Create new ObjVer object from a JSON string.

Syntax

Function ObjVerFromJSON(json As String) As ObjVer

Parameters

Name | Data Type | Description
json | String | Valid JSON string

Return

Returns an ObjVer

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

dim jsonString : jsonString = ObjVer.ToJSON

'new object from json string

Dim newObjVer

set newObjVer = scriptLib.ObjVerFromJSON(jsonString)


PreviousWorkflowStateEquals

Script Functions ››

Description

Determines if the previous version has the specified Workflow State.

Syntax

Function PreviousWorkflowStateEquals(Vault As Vault, ObjVer As ObjVer, WorkflowState As Object) As Boolean

Parameters

Name | Data Type | Description
Vault | Vault | Vault containing the objects to process
ObjVer | ObjVer | ObjVer of the object to test.
WorkflowState | String / Integer | Workflow State ID or Alias

Return

Returns True if the previous Workflow State matches that of the specified state. Otherwise returns False.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'previous workflow state equals

result = scriptLib.PreviousWorkflowStateEquals(Vault, ObjVer, "ExDOCS.State.WIPApproved")


RemoveAllFiles

Script Functions ››

Description

Removes all files in a Multi File Document object, The object must be checked out.

Syntax

Sub RemoveAllFiles(Vault As Vault, ObjVer As ObjVer)

Parameters

Name | Data Type | Description
Vault | Vault | The vault containing the object to process
ObjVer | ObjVer | ObjVer of thr object to process.

Return

No return value.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'remove all files

scriptLib.RemoveAllFiles Vault, ObjVer


RemoveFilesWithExtension

Script Functions ››

Description

Removes all the files in a Multi File Document object with the specified file extension, The object must be check out.

Syntax

Sub RemoveFilesWithExtension(Vault As Vault, ObjVer As ObjVer, Extension As String)

Parameters

Name | Data Type | Description
Vault | Vault | The vault containing the object to process
ObjVer | ObjVer | ObjVer of the object to process.
Extension | String | Extension of files to remove

Return

No return value.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'remove files with PDF extension

scriptLib.RemoveFilesWithExtension Vault, ObjVer, "PDF"


RenameFilesToObjectName

Script Functions ››

Description

Renames all the files in a Multi File Document object to the same name as the containing object, The object must be checked out. All the files in the Multi File Document must have different file extensions. Otherwise the method will fail due to duplicate filenames.

Syntax

Sub RenameFilesToObjectName(Vault As Vault, ObjVer As ObjVer)

Parameters

Name | Data Type | Description
Vault | Vault | Vault object containing the object to process
ObjVer | ObjVer | ObjVer of the object to process

Return

No return value.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'rename files to object name

scriptLib.RenameFilesToObjectName Vault, ObjVer


SetAssignment

Script Functions ››

Description

Set the Assigned to User, Assignment Description and optionally the Deadline Date.

Syntax

Sub SetAssignment(Vault As Vault, ObjVer As ObjVer, UserID As Integer, Description As String, Deadline As Object)

Parameters

Name | Data Type | Description
Vault | Vault | Vault that contains the Object to process
ObjVer | ObjVer | ObjVer of the object to process.
UserID | Integer | ID of the User to assign the object to
Description | String | Description to set on the assignment
Deadline | Object | the Deadline of the assignment in UK format (dd/mm/yyyy)

Return

No return value.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'set assignment

scriptLib.SetAssignment Vault, ObjVer, 1, "Description", "01/02/2020"


SetModifiedBy

Script Functions ››

Description

When modifying objects in an event handler, the object is shown as modified by (M-Files Server), Use this the method to set the modifying user to the specified User ID.

The specified object must be in a Checked Out state.

Syntax

Sub SetModifiedBy(Vault As Vault, ObjVer As ObjVer, UserID As Object)

Parameters

Name | Data Type | Description
Vault | Vault | The Vault object provided by the event handler.
ObjVer | ObjVer | ObjVer of object to process. This could be provided by the event handler or created dynamically using CreateObject("MFilesAPI.ObjVer").
UserID | Integer or TypedValue | The ID of the desired modifying user.

Return

No return value.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'set modifying user

scriptLib.SetModifiedBy Vault, ObjVer, CurrentUserID


SetMultipleProperties

Script Functions ››

Description

Allows setting multiple properties on an ObjVer in a 'batch' this can be more efficient than setting each property individually or in a loop.

Syntax

Function SetMultipleProperties(Vault As Vault, ObjVer As ObjVer, Properties As PropertyList)

Parameters

Name | Data Type | Description
Vault | Vault | The Vault object provided by the event handler.
ObjVer | ObjVer | ObjVer of object to process. This could be provided by the event handler or created dynamically using CreateObject("MFilesAPI.ObjVer").
Properties | PropertyList | The list of properties and values to set

Return

ObjectVersionAndProperties that represents the updated ObjVer

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

Dim PropList : set PropList = scriptLib.NewPropertyListObject

PropList.Add "ExDOCS.Property.Watermark","NOT FOR CONSTRUCTION"

'set multiple properties

scriptLib.SetMultipleProperties Vault, ObjVer, PropList

See Also

PropertyList


SetNamedValue

Script Functions ››

Description

Sets the named value in the collection in the given namespace.

Syntax

Sub SetNamedValue(Namespace As String, ValueName As String, Value As Object)

Parameters

Name | Data Type | Description
Namespace | String | Unique identifier for the value collection
ValueName | String | Name of the value to set
Value | String | Value to set

Return

No return value.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'set named value

scriptLib.SetNamedValue "Namespace", "ValueName", "Value"


SetPropertyValue

Script Functions ››

Description

Sets a property value on the specified object using the Property ID or Property Alias.

Syntax

Sub SetPropertyValue(Vault As Vault, ObjVer As ObjVer, Property As Object, Value As Object)

Parameters

Name | Data Type | Description
Vault | Vault | Vault object containing the Object to process
ObjVer | ObjVer | ObjVer of the object to process
Property | Integer or String | The property ID or the property alias
Value | Object | New property value

Return

No return value.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'set 'Name or Title' property value

scriptLib.SetPropertyValue Vault, ObjVer, 0, "New Object Name"


SetWorkflowAndState

Script Functions ››

Description

Set Workflow and State of the specified object. The object must be checked out.

Syntax

Sub SetWorkflowAndState(Vault As Vault, ObjVer As ObjVer, Workflow As Object, State As Object)

Parameters

Name | Data Type | Description
Vault | Vault | The Vault object provided by the event handler.
ObjVer | ObjVer | ObjVer of the target object
Workflow | Object | Target Workflow ID or alias
State | Object | Target State ID or alias. the State must be valid state of the specified workflow

Return

Not return value.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'set Workflow and State

scriptLib.SetWorkflowAndState Vault, ObjVer, "ExDOCS.Workflow.CDEShared", "ExDOCS.State.PrepareToShare"


WriteLog

Script Functions ››

Description

Writes a custom message to a log file, Please see Log Files for more information.

Syntax

Sub WriteLog(LogIdentifier As Object, Message As Object)

Parameters

Name | Data Type | Description
LogIdentifier | String or TypedValue | Used to determine the filename of the log file. To create a log file for the current activity pass in the provided ActivityID.
Message | Object | A String or Object to write to the log file. If an object is specified, it must be convertible to String.

Return

No return value.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'write to log

scriptLib.WriteLog ActivityID, "Message 1"

scriptLib.WriteLog ActivityID, "Message 2"

scriptLib.WriteLog ActivityID, "Message 3"

The resulting log file would contain the following information:

01/01/2019 09:00:00:8802 - Message 1

01/01/2019 09:00:00:8922 - Message 2

01/01/2019 09:00:00:8932 - Message 3


Types

Copyright © Pentagon Solutions Ltd. All Rights Reserved.


RelatedDocuments

Types ››

Description

Returns an object that contains all the document objects related by a common value of the specified property.

Methods

Name | Description
FilterByWorkflowStates | Returns an object that contains all the document objects that are in the specified states

Properties

Name | Description
Items | Returns all Items contained within the RelatedDocuments object.


Properties

Types ›› RelatedDocuments ››


Items

Types ›› RelatedDocuments ›› Properties ››

Description

Returns all the Items contained within the RelatedDocuments object.

Syntax

ReadOnly Property Items As ObjVer()

Parameters

No Parameters.

Return

Returns an array of ObjVer objects that all share a common value.


Methods

Types ›› RelatedDocuments ››


FilterByWorkflowStates

Types ›› RelatedDocuments ›› Methods ››

Description

Returns an object that contains all the document objects that are in the specified states.

Syntax

Function FilterByWorkflowStates(WorkflowStates() As Object) As Object()

Parameters

Name | Data Type | Description
WorkflowStates | Array of String or Integers | An Array of Workflow State ID's or Workflow State Alias

Return

Returns a RelatedDocuments object. See RelatedDocuments object for more details.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'get related documents

Set relatedDocs = scriptLib.GetRelatedDocuments(Vault, "ExDOCS.Property.BaseDocumentNumber", "P001-EXC-ZZ-00-DR-A-0001")

'filter by workflow state

Set result = relatedDocs.FilterByWorkflowStates(Array("ExDOCS.State.Shared", "ExDOCS.State.Published"))


FilterByProperty

Types ›› RelatedDocuments ›› Methods ››

Description

Returns an object that contains all the document objects that match the specified filter.

Syntax

Function FilterByProperty(Property As Object, propertyValues() As Object)

Parameters

Name | Data Type | Description
Property | Integer or String | The property ID or the property alias
PropertyValues | Array of String or Integers | An Array of Strings

Return

Returns a RelatedDocuments object. See RelatedDocuments object for more details.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'get related documents

Set relatedDocs = scriptLib.GetRelatedDocuments(Vault, "ExDOCS.Property.BaseDocumentNumber", "P001-EXC-ZZ-00-DR-A-0001")

'filter by workflow state

Set result = relatedDocs.FilterByProperty("ExDOCS.Property.Suitability", Array("S1", "S2", "S3"))


CopyObjectConfiguration

Types ››

Description

Returns an object that is used to define the Object to be copied.

Methods

Name | Description
ToJson | Returns an object that contains all the document objects that are in the specified states
GetSourceObjVer | Gets the Source ObjVer
GetReturnObjVer | Gets the Return ObjVer
SetSourceObjVer | Set the source Object of the object to be returned to the process
SetReturnObjVer | Set the ObjVer of object to be returned to the process

Properties

Name | Description
Successful | Gets or Sets the boolean property to feedback to the process completed successfully.
ErrorMessage | Gets or Sets the string property to feedback to the process what has caused an Error.
WorkflowAlias | Gets or Sets the property to feedback to the process the Workflow Alias
StateAlias | Gets or Sets the property to feedback to the process the State Alias
DestroySourceObject | Gets or Sets the property to indicate if the source object should be destroyed


Properties

Types ›› CopyObjectConfiguration ››


Successful

Types ›› CopyObjectConfiguration ›› Properties ››

Description

Gets or Sets the Boolean property to feedback to that the process completed successfully.

Syntax

Property Successful As Boolean

Parameters

No Parameters.

Return

Returns the Boolean value of the property.


ErrorMessage

Types ›› CopyObjectConfiguration ›› Properties ››

Description

Gets or Sets the message returned from the script processing if there has been any errors.

Syntax

Property ErrorMessage As String

Parameters

No Parameters.

Return

Returns the string value


WorkflowAlias

Types ›› CopyObjectConfiguration ›› Properties ››

Description

Gets or Sets the string property of the WorkFlow alias.

Syntax

Property WorkflowAlias As String

Parameters

No Parameters.

Return

Returns the string value.


StateAlias

Types ›› CopyObjectConfiguration ›› Properties ››

Description

Gets or Sets the property indicating the state alias.

Syntax

Property StateAlias As String

Parameters

No Parameters.

Return

Returns the string value.


DestroySourceObject

Types ›› CopyObjectConfiguration ›› Properties ››

Description

Gets or Sets the Boolean property indicate the source object should be destroyed.

Syntax

Property DestroySourceObject As Boolean

Parameters

No Parameters.

Return

Returns the Boolean value of the property.


Methods

Types ›› CopyObjectConfiguration ››


ToJson

Types ›› CopyObjectConfiguration ›› Methods ››

Description

Returns a string containing the serialised object and all of its properties.

Syntax

Function ToJson() As String

Parameters

None

Return

String.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'ToJson

set copyObjConf = scriptLib.GetCopyObjectConfiguration("jsonString")

dim jsonStr

jsonStr = copyObjConf.ToJson()


GetSourceObjVer

Types ›› CopyObjectConfiguration ›› Methods ››

Description

Returns the ObjVer that represents the Source Object.

Syntax

Function GetSourceObjVer() As ObjVer

Parameters

None

Return

ObjVer

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'get source ObjVer

set copyObjConf = scriptLib.GetCopyObjectConfiguration("jsonString")

dim srcObjVer

srcObjVer = copyObjConf.GetSourceObjVer()


GetReturnObjVer

Types ›› CopyObjectConfiguration ›› Methods ››

Description

Returns an ObjVer that represents the Object to return.

Syntax

Function GetReturnObjVer() As ObjVer

Parameters

None

Return

ObjVer

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'return source ObjVer

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

set copyObjConf = scriptLib.GetCopyObjectConfiguration("jsonString")

dim retObjVer

retObjVer = copyObjConf.GetReturnObjVer()


SetSourceObjVer

Types ›› CopyObjectConfiguration ›› Methods ››

Description

Sets the ObjVer that relates tot he Source Object.

Syntax

Sub SetSourceObjVer(objVer As ObjVer)

Parameters

Name | Data Type | Description
ObjVer | ObjVer | ObjVer of the Object to use as the source

Return

Nothing

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'set source ObjVer

Set copyObjConf = scriptLib.GetCopyObjectConfiguration("jsonString")

copyObjConf.SetSourceObjVer(ObjVer)


SetReturnObjVer

Types ›› CopyObjectConfiguration ›› Methods ››

Description

Sets the ObjVer that relates to the Object to return.

Syntax

Sub SetReturnObjVer(objVer As ObjVer)

Parameters

Name | Data Type | Description
ObjVer | ObjVer | ObjVer of the object to set as the return

Return

Nothing

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'set return ObjVer

set copyObjConf = scriptLib.GetCopyObjectConfiguration("jsonString")

copyObjConf.SetReturnObjVer(ObjVer)


TempPublishData

Types ››

Description

Returns an object that is used to define the Temporary Object to be published.

Methods

Name | Description
ToJson | Returns an object that contains all the document objects that are in the specified states
GetTempObjVer |

Properties

Name | Description
Successful | Returns all Items contained within the RelatedDocuments object.
TargetState |
UserProperty |
DestroySourceObject |


Properties

Types ›› TempPublishData ››


Successful

Types ›› TempPublishData ›› Properties ››

Description

Gets or Sets the Boolean property to feedback to that the process completed successfully.

Syntax

Property Successful As Boolean

Parameters

No Parameters.

Return

Returns the Boolean value of the property.


TargetState

Types ›› TempPublishData ›› Properties ››

Description

Gets or Sets the TargetState for the Object being processed.

Syntax

Property TargetState As String

Parameters

No Parameters.

Return

Returns the String value of the property.


UserProperty

Types ›› TempPublishData ›› Properties ››

Description

Gets or Sets the Boolean property to feedback to that the process completed successfully.

Syntax

Property UserProperty As Dictionary(Of String,String)

Parameters

No Parameters.

Return

Returns a Dictionary Of String,String.


DestroyTempObject

Types ›› TempPublishData ›› Properties ››

Description

Gets or Sets the Boolean property to indicate the temporary object should be destroyed.

Syntax

Property DestroyTempObject As Boolean

Parameters

No Parameters.

Return

Returns the Boolean value of the property.


Methods

Types ›› TempPublishData ››


ToJSON

Types ›› TempPublishData ›› Methods ››

Description

Returns a string containing the serialised object.

Syntax

Function ToJson() As String

Parameters

None

Return

String

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'ToJson

Set tempPublishObj = scriptLib.GetTempPublishData("josnString")

Dim JsonStr

jsonStr = tempPublishObj.ToJson()


GetTempObjVer

Types ›› TempPublishData ›› Methods ››

Description

Returns the ObjVer that has been assigned as the Temp Object.

Syntax

Function GetTempObjVer() As ObjVer

Parameters

None

Return

ObjVer

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'get temp ObjVer

Set tempPublishObj = scriptLib.GetTempPublishData("josnString")

Dim tempObjVer

Set tempObjVer = tempPublishObj.GetTempObjVer()


StringKvPCollection

Types ››

Description

Returns an object that can be used to store a collection of strings indexed by a key, this collection is not ordered and as such it is best to access items via there key.

Methods

Name | Description
Add | Adds a new item to the collection
Remove | Removes an item from the collection
Contains | Returns a boolean indicating if a particular key already exists
ToJSON | Converts the collection to a JSON string
FromJSON | Populates the collection from a JSON string

Properties

Name | Description
Keys | Returns all keys in the collection
Items | Returns all Items in the collection
Item | Returns the Item specified by a particular Key


Properties

Types ›› StringKvPCollection ››


Keys

Types ›› StringKvPCollection ›› Properties ››

Description

Gets a list of all the Keys held in the collection, This property is ReadOnly

Syntax

Property Keys As String()

Parameters

No Parameters.

Return

Returns the string array of all the Keys


Items

Types ›› StringKvPCollection ›› Properties ››

Description

Gets a list of all the items in the collection. This property is ReadOnly and only returns the unordered items

Syntax

Property Items As String()

Parameters

No Parameters.

Return

Returns items in the collection as a string array.


Item

Types ›› StringKvPCollection ›› Properties ››

Description

Gets or Sets the value of a specified key.

Syntax

Property Item(key As String) As String

Parameters

Key of existing the item to Get or Set.

Return

Returns a String.


Methods

Types ›› StringKvPCollection ››


Add

Types ›› StringKvPCollection ›› Methods ››

Description

Adds a new item to the collection.

Syntax

Sub Add(key As String, value As String)

Parameters

Name | Data Type | Description
Key | String | A unique string to identify the value by
ObjVer | String | The string value to store

Return

None

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'add key value pair

Dim newKVP : Set newKVP = scriptLib.NewStringKvP

newKvP.Add "KeyName","NewValue"


FromJSON

Types ›› StringKvPCollection ›› Methods ››

Description

Populates the collection with the values from a JSON string.

Syntax

Sub FromJSON(jsonString As String)

Parameters

A string value that represents a serialised collection

Return

none

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'add key value pairs

Dim newKVP : Set newKVP = scriptLib.NewStringKvP

newKvP.Add "KeyName1","NewValue"

newKvP.Add "KeyName2","NewValue"

newKvP.Add "KeyName3","NewValue"

'ToJson

Dim JsonStr : jsonStr = newKVP.ToJson()

'FromJSON

newKvP.FromJSON(JsonStr)


ToJSON

Types ›› StringKvPCollection ›› Methods ››

Description

Populates the collection with the values from a JSON string.

Syntax

Sub FromJSON(jsonString As String)

Parameters

A string value that represents a serialised collection

Return

none

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'add key value pairs

Dim newKVP : Set newKVP = scriptLib.NewStringKvP

newKvP.Add "KeyName1","NewValue"

newKvP.Add "KeyName2","NewValue"

newKvP.Add "KeyName3","NewValue"

'ToJson

Dim JsonStr : jsonStr = newKVP.ToJson()

'FromJSON

newKvP.FromJSON(JsonStr)


Remove

Types ›› StringKvPCollection ›› Methods ››

Description

Removes an item from the collection.

Syntax

Sub Remove(key As String)

Parameters

Name | Data Type | Description
Key | String | the Key that identifies the value to remove

Return

None

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'add key value pairs

Dim newKVP : Set newKVP = scriptLib.NewStringKvP

newKvP.Add "KeyName1","NewValue"

newKvP.Add "KeyName2","NewValue"

newKvP.Add "KeyName3","NewValue"

'remove

newKvP.Remove "KeyName2"


Contains

Types ›› StringKvPCollection ›› Methods ››

Description

Checks if a specified Key already exists.

Syntax

Function Contains(key As String) As Boolean

Parameters

Name | Data Type | Description
Key | String | Key to check the collection for

Return

Boolean value indicating if the key is already in the collection or not.

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'add key value pairs

Dim newKVP : Set newKVP = scriptLib.NewStringKvP

newKvP.Add "KeyName1","NewValue"

newKvP.Add "KeyName2","NewValue"

newKvP.Add "KeyName3","NewValue"

'contains

Dim keyExists : keyExists = newKVP.Contains("KeyName2")


PropertyList

Types ››

Description

Returns an object that can be used to store a collection of properties to update an ObjVer.

Methods

Name | Description
Add | Adds a new property to the list

Properties

None


Methods

Types ›› PropertyList ››


Add

Types ›› PropertyList ›› Methods ››

Description

Adds a new item to the collection.

Syntax

Sub Add(Property As Object, value As Object)

Parameters

Name | Data Type | Description
Property | String or Integer | Property ID or Alias
Value | Object | New Property value

Return

None

Example

'create Pentagon DOCS Script Library object

Set scriptLib = GetExtensionObject("PentagonDOCS.Core.ScriptLibrary")

'add to property list

Dim propList : Set propList = scriptLib.NewPropertyList

propList.Add "PropertyAlias","NewValue"

propList.Add 1234,"NewValue2"


Support

Core Script Library for M-Files

For support related to the installation and or usage of this Application, please contact:

Head Office
Pentagon Ltd
Design Technology Centre
8 Kinetic Crescent
Innova Business Park
Enfield, Middlesex
EN3 7XH

Pentagon Support

T: 01992 700 188
E: support@Pentagon.co.uk
www.Pentagon.co.uk